
#ifndef MEDIA_RECORD_COMMAND_IN_H_
#define MEDIA_RECORD_COMMAND_IN_H_

#include "command.h"

#pragma pack(1)
namespace Cmd
{
        namespace MediaRecord
        {
                //  cmd declaration
                enum {
                        CMDIN_LOGIN             = 0x0010,       // 登录MediaRecordServer验证指令
                        CMDIN_ROOM              = 0x0011,       // 与RoomServer交互的指令
                };

                // CMDIN_LOGIN
                enum {
                        SCMDIN_LOGIN                            = 0x0001,       // 请求登录MediaRecordServer
                        SCMDIN_LOGIN_RESPONCE                   = 0x0002,	// 登录MediaRecordServer返回
                };
                // CMDIN_ROOM
                enum {
                        SCMDIN_RECORDING_SPEAKING_LIST_NOTIFY   = 0x0003,       // 通知说话用户列表
                        SCMDIN_RECORDING_ADD_SPEAKING_NOTIFY    = 0x0004,       // 通知增加说话用户
                        SCMDIN_RECORDING_DEL_SPEAKING_NOTIFY    = 0x0005,       // 通知减少说话用户
                        SCMDIN_RECORDING_REQ_RECORD_ADDR        = 0x0006,       // RoomServer请求MediaRecordServer的录音地址
                        SCMDIN_RECORDING_RES_RECORD_ADDR        = 0x0007,       // MediaRecordServer返回自己的录音地址
                        SCMDIN_RECORDING_OPEN_BOARD_NOTIFY      = 0x0008,       // 通知开打（黑板）
                        SCMDIN_RECORDING_CLOSE_BOARD_NOTIFY     = 0X0009,       // 通知关闭（黑板）
                        SCMDIN_RECORDING_TURN_PAGE_NOTIFY       = 0x000A,       // 通知翻页
                        SCMDIN_RECORDING_START_RECORD_NOTIFY    = 0x000B,       // 通知开始转发数据
                        SCMDIN_RECORDING_STOP_RECORD_NOTIFY     = 0x000C,       // 通知结束转发数据
                };

                // cmd login
                struct stLoginCmd:t_NullCmd
                {
                        stLoginCmd():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN)
                        {
                                server_type_ = 0;
                                server_id_ = 0;
                                dest_type_ = MEDIARECORDSERVER;
                        }
                        WORD server_type_;
                        DWORD server_id_;
                        WORD dest_type_;
                };

                struct stLoginResponce:t_NullCmd
                {
                        stLoginResponce():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_RESPONCE)
                        {
                        }
                };

                // cmd room
                struct stRoomCmdBase : t_NullCmd
                {
                        stRoomCmdBase(WORD subcmd)
                                : t_NullCmd(CMDIN_ROOM, subcmd)
                        {
                                room_id_ = 0;
                        }

                        DWORD room_id_;
                };

                struct stRoomRecordingSpeakingListNotify : stRoomCmdBase
                {
                        stRoomRecordingSpeakingListNotify()
                                : stRoomCmdBase(SCMDIN_RECORDING_SPEAKING_LIST_NOTIFY)
                        {
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        WORD size_;
                        char json_[0];
                        // json_ = speaker_info(value)...
                        // speaker_info = speaker_id(uint)
                };

                struct stRoomRecordingAddSpeakingNotify : stRoomCmdBase
                {
                        stRoomRecordingAddSpeakingNotify()
                                : stRoomCmdBase(SCMDIN_RECORDING_ADD_SPEAKING_NOTIFY)
                        {
                                speaker_id_ = 0;
                        }

                        DWORD speaker_id_;
                };

                struct stRoomRecordingDelSpeakingNotify : stRoomCmdBase
                {
                        stRoomRecordingDelSpeakingNotify()
                                : stRoomCmdBase(SCMDIN_RECORDING_DEL_SPEAKING_NOTIFY)
                        {
                                speaker_id_ = 0;
                        }

                        DWORD speaker_id_;
                };

                struct stRoomRecordingReqRecordAddr : stRoomCmdBase
                {
                        stRoomRecordingReqRecordAddr():
                                stRoomCmdBase(SCMDIN_RECORDING_REQ_RECORD_ADDR)
                        {
                        }
                };
                struct stRoomRecordingResRecordAddr : stRoomCmdBase
                {
                        stRoomRecordingResRecordAddr():
                                stRoomCmdBase(SCMDIN_RECORDING_RES_RECORD_ADDR)
                        {
                                bzero(ip_, sizeof(ip_));
                                port_ = 0;
                        }
                        char ip_[MAX_IP_LENGTH+1];
                        WORD port_;
                };

                struct stRoomRecordingOpenBoardNotify : stRoomCmdBase
                {
                        stRoomRecordingOpenBoardNotify()
                                : stRoomCmdBase(SCMDIN_RECORDING_OPEN_BOARD_NOTIFY)
                        {
                                size_ = 0;
                        }

                        DWORD getSize() const
                        {
                                return sizeof(*this) + size_*sizeof(json_[0]);
                        }

                        WORD size_;
                        char json_[0];
                        // json_ = url(str) + page(uint)
                };

                struct stRoomRecordingCloseBoardNotify : stRoomCmdBase
                {
                        stRoomRecordingCloseBoardNotify()
                                : stRoomCmdBase(SCMDIN_RECORDING_CLOSE_BOARD_NOTIFY)
                        {
                        }
                };

                struct stRoomRecordingTurnPageNotify : stRoomCmdBase
                {
                        stRoomRecordingTurnPageNotify()
                                : stRoomCmdBase(SCMDIN_RECORDING_TURN_PAGE_NOTIFY)
                        {
                                page_ = 0;
                        }

                        DWORD page_;
                };

                struct stRoomRecordingStartNotification : stRoomCmdBase
                {
                        stRoomRecordingStartNotification() :
                                stRoomCmdBase(SCMDIN_RECORDING_START_RECORD_NOTIFY)
                        {
                                
                        }        
                        uint32_t record_id;
                };

                struct stRoomRecordingStopNotification : stRoomCmdBase
                {
                        stRoomRecordingStopNotification() :
                                stRoomCmdBase(SCMDIN_RECORDING_STOP_RECORD_NOTIFY)
                        {

                        }
                };
        };      // namespace MediaRecord
};      // namespace Cmd

#pragma pack()  // pack(1)

#endif  // MEDIA_RECORD_COMMAND_IN_H_
